<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>perlcn - 简体中文 Perl 指南 - Perldoc Browser</title>
    <link rel="search" href="https://perldoc.perl.org/opensearch.xml" type="application/opensearchdescription+xml" title="Perldoc Browser">
    <link rel="canonical" href="https://perldoc.perl.org/perlcn">
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.5.0/styles/stackoverflow-light.min.css" integrity="sha512-cG1IdFxqipi3gqLmksLtuk13C+hBa57a6zpWxMeoY3Q9O6ooFxq50DayCdm0QrDgZjMUn23z/0PMZlgft7Yp5Q==" crossorigin="anonymous" />
    <style>
      body {
        background: #f4f4f5;
        color: #020202;
      }
      .navbar-dark {
        background-image: -webkit-linear-gradient(top, #005f85 0, #002e49 100%);
        background-image: -o-linear-gradient(top, #005f85 0, #002e49 100%);
        background-image: linear-gradient(to bottom, #005f85 0, #002e49 100%);
        filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff005f85', endColorstr='#ff002e49', GradientType=0);
        background-repeat: repeat-x;
      }
      .navbar-dark .navbar-nav .nav-link,
      .navbar-dark .navbar-nav .nav-link:focus { color: #fff }
      .navbar-dark .navbar-nav .nav-link:hover { color: #ffef68 }
      #wrapperlicious {
        margin: 0 auto;
        font: 0.9em 'Helvetica Neue', Helvetica, sans-serif;
        font-weight: normal;
        line-height: 1.5em;
        margin: 0;
        padding: 0;
      }
      #wrapperlicious h1 { font-size: 1.5em }
      #wrapperlicious h2 { font-size: 1.3em }
      #wrapperlicious h3 { font-size: 1.1em }
      #wrapperlicious h4 { font-size: 0.9em }
      #wrapperlicious h1, #wrapperlicious h2, #wrapperlicious h3,
      #wrapperlicious h4, #wrapperlicious dt {
        color: #020202;
        margin-top: 1em;
        margin-bottom: 1em;
        position: relative;
        font-weight: bold;
      }
      #wrapperlicious a { color: inherit; text-decoration: underline }
      #wrapperlicious #toc { text-decoration: none }
      #wrapperlicious a:hover { color: #2a2a2a }
      #wrapperlicious a img { border: 0 }
      #wrapperlicious :not(pre) > code {
        color: inherit;
        background-color: rgba(0, 0, 0, 0.04);
        border-radius: 3px;
        font: 0.9em Consolas, Menlo, Monaco, monospace;
        padding: 0.3em;
      }
      #wrapperlicious dd {
        margin: 0;
        margin-left: 2em;
      }
      #wrapperlicious dt {
        color: #2a2a2a;
        font-weight: bold;
        margin-left: 0.9em;
      }
      #wrapperlicious p {
        margin-bottom: 1em;
        margin-top: 1em;
      }
      #wrapperlicious li > p {
        margin-bottom: 0;
        margin-top: 0;
      }
      #wrapperlicious pre {
        border: 1px solid #c1c1c1;
        border-radius: 3px;
        font: 100% Consolas, Menlo, Monaco, monospace;
        margin-bottom: 1em;
        margin-top: 1em;
      }
      #wrapperlicious pre > code {
        display: block;
        background-color: #f6f6f6;
        font: 0.9em Consolas, Menlo, Monaco, monospace;
        line-height: 1.5em;
        text-align: left;
        white-space: pre;
        padding: 1em;
      }
      #wrapperlicious dl, #wrapperlicious ol, #wrapperlicious ul {
        margin-bottom: 1em;
        margin-top: 1em;
      }
      #wrapperlicious ul {
        list-style-type: square;
      }
      #wrapperlicious ul ul {
        margin-bottom: 0px;
        margin-top: 0px;
      }
      #footer {
        font-size: 0.8em;
        padding-top: 0.5em;
        text-align: center;
      }
      #more {
        display: inline;
        font-size: 0.8em;
      }
      #perldocdiv {
        background-color: #fff;
        border: 1px solid #c1c1c1;
        border-bottom-left-radius: 5px;
        border-bottom-right-radius: 5px;
        margin-left: auto;
        margin-right: auto;
        padding: 3em;
        padding-top: 1em;
        max-width: 960px;
      }
      #moduleversion { float: right }
      #wrapperlicious .leading-notice {
        font-style: italic;
        padding-left: 1em;
        margin-top: 1em;
        margin-bottom: 1em;
      }
      #wrapperlicious .permalink {
        display: none;
        left: -0.75em;
        position: absolute;
        padding-right: 0.25em;
        text-decoration: none;
      }
      #wrapperlicious h1:hover .permalink, #wrapperlicious h2:hover .permalink,
      #wrapperlicious h3:hover .permalink, #wrapperlicious h4:hover .permalink,
      #wrapperlicious dt:hover .permalink {
        display: block;
      }
    </style>
    <!-- Global site tag (gtag.js) - Google Analytics -->
    <script async src="https://www.googletagmanager.com/gtag/js?id=G-KVNWBNT5FB"></script>
    <script>
      window.dataLayer = window.dataLayer || [];
      function gtag(){dataLayer.push(arguments);}
      gtag('js', new Date());

      gtag('config', 'G-KVNWBNT5FB');
      gtag('config', 'UA-50555-3');
    </script>
  </head>
  <body>
    <nav class="navbar navbar-expand-md navbar-dark bg-dark justify-content-between">
  <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon"></span>
  </button>
  <a class="navbar-brand" href="https://perldoc.perl.org/">Perldoc Browser</a>
  <div class="collapse navbar-collapse" id="navbarNav">
    <ul class="navbar-nav mr-auto">
      <li class="nav-item dropdown text-nowrap">
        <a class="nav-link dropdown-toggle" href="perlcn.html#" id="dropdownlink-stable" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">5.35.0</a>
        <div class="dropdown-menu" aria-labelledby="dropdownlink-stable">
          <a class="dropdown-item" href="https://perldoc.perl.org/perlcn">Latest</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.2/perlcn">5.38.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.1/perlcn">5.38.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.0/perlcn">5.38.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.3/perlcn">5.36.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.2/perlcn">5.36.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.1/perlcn">5.36.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.0/perlcn">5.36.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.3/perlcn">5.34.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.2/perlcn">5.34.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.1/perlcn">5.34.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.0/perlcn">5.34.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.32.1/perlcn">5.32.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.32.0/perlcn">5.32.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.3/perlcn">5.30.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.2/perlcn">5.30.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.1/perlcn">5.30.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.0/perlcn">5.30.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.3/perlcn">5.28.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.2/perlcn">5.28.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.1/perlcn">5.28.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.0/perlcn">5.28.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.3/perlcn">5.26.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.2/perlcn">5.26.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.1/perlcn">5.26.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.0/perlcn">5.26.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.4/perlcn">5.24.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.3/perlcn">5.24.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.2/perlcn">5.24.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.1/perlcn">5.24.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.0/perlcn">5.24.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.4/perlcn">5.22.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.3/perlcn">5.22.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.2/perlcn">5.22.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.1/perlcn">5.22.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.0/perlcn">5.22.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.3/perlcn">5.20.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.2/perlcn">5.20.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.1/perlcn">5.20.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.0/perlcn">5.20.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.4/perlcn">5.18.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.3/perlcn">5.18.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.2/perlcn">5.18.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.1/perlcn">5.18.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.0/perlcn">5.18.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.3/perlcn">5.16.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.2/perlcn">5.16.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.1/perlcn">5.16.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.0/perlcn">5.16.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.4/perlcn">5.14.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.3/perlcn">5.14.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.2/perlcn">5.14.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.1/perlcn">5.14.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.0/perlcn">5.14.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.5/perlcn">5.12.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.4/perlcn">5.12.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.3/perlcn">5.12.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.2/perlcn">5.12.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.1/perlcn">5.12.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.0/perlcn">5.12.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.10.1/perlcn">5.10.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.10.0/perlcn">5.10.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.9/perlcn">5.8.9</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.8/perlcn">5.8.8</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.7/perlcn">5.8.7</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.6/perlcn">5.8.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.5/perlcn">5.8.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.4/perlcn">5.8.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.3/perlcn">5.8.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.2/perlcn">5.8.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.1/perlcn">5.8.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.0/perlcn">5.8.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.6.2/perlcn">5.6.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.6.1/perlcn">5.6.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.6.0/perlcn">5.6.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_04/perlcn">5.005_04</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_03/perlcn">5.005_03</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_02/perlcn">5.005_02</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_01/perlcn">5.005_01</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005/perlcn">5.005</a>
        </div>
      </li>
      <li class="nav-item dropdown text-nowrap">
        <a class="nav-link dropdown-toggle" href="perlcn.html#" id="dropdownlink-dev" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Dev</a>
        <div class="dropdown-menu" aria-labelledby="dropdownlink-dev">
          <a class="dropdown-item" href="https://perldoc.perl.org/blead/perlcn">blead</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.6/perlcn">5.39.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.5/perlcn">5.39.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.4/perlcn">5.39.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.3/perlcn">5.39.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.2/perlcn">5.39.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.1/perlcn">5.39.1</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.0-RC2/perlcn">5.38.0-RC2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.0-RC1/perlcn">5.38.0-RC1</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.11/perlcn">5.37.11</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.10/perlcn">5.37.10</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.9/perlcn">5.37.9</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.8/perlcn">5.37.8</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.7/perlcn">5.37.7</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.6/perlcn">5.37.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.5/perlcn">5.37.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.4/perlcn">5.37.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.3/perlcn">5.37.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.2/perlcn">5.37.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.1/perlcn">5.37.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.0/perlcn">5.37.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.11/perlcn">5.35.11</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.10/perlcn">5.35.10</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.9/perlcn">5.35.9</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.8/perlcn">5.35.8</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.7/perlcn">5.35.7</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.6/perlcn">5.35.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.5/perlcn">5.35.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.4/perlcn">5.35.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.3/perlcn">5.35.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.2/perlcn">5.35.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.1/perlcn">5.35.1</a>
          <a class="dropdown-item active" href="perlcn.html">5.35.0</a>
        </div>
      </li>
      <li class="nav-item dropdown text-nowrap">
        <a class="nav-link dropdown-toggle" href="perlcn.html#" id="dropdownlink-nav" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Documentation</a>
        <div class="dropdown-menu" aria-labelledby="dropdownlink-nav">
          <a class="dropdown-item" href="perl.html">Perl</a>
          <a class="dropdown-item" href="perlintro.html">Intro</a>
          <a class="dropdown-item" href="perl.html#Tutorials">Tutorials</a>
          <a class="dropdown-item" href="perlfaq.html">FAQs</a>
          <a class="dropdown-item" href="perl.html#Reference-Manual">Reference</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="perlop.html">Operators</a>
          <a class="dropdown-item" href="functions.html">Functions</a>
          <a class="dropdown-item" href="variables.html">Variables</a>
          <a class="dropdown-item" href="modules.html">Modules</a>
          <a class="dropdown-item" href="perlutil.html">Utilities</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="perlcommunity.html">Community</a>
          <a class="dropdown-item" href="perlhist.html">History</a>
        </div>
      </li>
    </ul>
    <ul class="navbar-nav">
      <script>
        function set_expand (expand) {
          var perldocdiv = document.getElementById('perldocdiv');
          var width = window.getComputedStyle(perldocdiv).getPropertyValue('max-width');
          var expanded = (width == '' || width == 'none') ? true : false;
          if (expand === null) {
            expand = !expanded;
          }
          if ((expand && !expanded) || (!expand && expanded)) {
            perldocdiv.style.setProperty('max-width', expand ? 'none' : '960px');
            var button_classlist = document.getElementById('content-expand-button').classList;
            if (expand) {
              button_classlist.add('btn-light');
              button_classlist.remove('btn-outline-light');
            } else {
              button_classlist.add('btn-outline-light');
              button_classlist.remove('btn-light');
            }
          }
          return expand;
        }
        function toggle_expand () {
          var expand = set_expand(null);
          document.cookie = 'perldoc_expand=' + (expand ? 1 : 0) + '; path=/; expires=Tue, 19 Jan 2038 03:14:07 UTC';
        }
        function read_expand () {
          return document.cookie.split(';').some(function (item) { return item.indexOf('perldoc_expand=1') >= 0 });
        }
        if (document.readyState === 'loading') {
          document.addEventListener('DOMContentLoaded', function () {
            if (read_expand()) {
              set_expand(true);
            }
          });
        } else if (read_expand()) {
          set_expand(true);
        }
      </script>
      <button id="content-expand-button" type="button" class="btn btn-outline-light d-none d-lg-inline-block mr-2" onclick="toggle_expand()">Expand</button>
    <ul>
    <form class="form-inline" method="get" action="https://perldoc.perl.org/5.35.0/search">
      <input class="form-control mr-3" type="search" name="q" placeholder="Search" aria-label="Search">
    </form>
  </div>
</nav>

    <div id="wrapperlicious" class="container-fluid">
      <div id="perldocdiv">
        <div id="links">
          <a href="perlcn.html">perlcn</a>
          <div id="more">
            (<a href="perlcn.txt">source</a>,
            <a href="https://metacpan.org/pod/perlcn">CPAN</a>)
          </div>
        </div>
        <div class="leading-notice">
          You are viewing the version of this documentation from Perl 5.35.0.
            This is a development version of Perl.
        </div>
        <h1><a id="toc">CONTENTS</a></h1>
                  <ul>
              <li>
                <a class="text-decoration-none" href="perlcn.html#NAME">NAME</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlcn.html#DESCRIPTION">DESCRIPTION</a>
                            <ul>
              <li>
                <a class="text-decoration-none" href="perlcn.html#%E9%A2%9D%E5%A4%96%E7%9A%84%E4%B8%AD%E6%96%87%E7%BC%96%E7%A0%81">额外的中文编码</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlcn.html#%E8%BF%9B%E4%B8%80%E6%AD%A5%E7%9A%84%E4%BF%A1%E6%81%AF">进一步的信息</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlcn.html#%E6%8F%90%E4%BE%9B-Perl-%E8%B5%84%E6%BA%90%E7%9A%84%E7%BD%91%E5%9D%80">提供 Perl 资源的网址</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlcn.html#%E5%AD%A6%E4%B9%A0-Perl-%E7%9A%84%E7%BD%91%E5%9D%80">学习 Perl 的网址</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlcn.html#Perl-%E4%BD%BF%E7%94%A8%E8%80%85%E9%9B%86%E4%BC%9A">Perl 使用者集会</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlcn.html#Unicode-%E7%9B%B8%E5%85%B3%E7%BD%91%E5%9D%80">Unicode 相关网址</a>
              </li>
          </ul>

              </li>
              <li>
                <a class="text-decoration-none" href="perlcn.html#SEE-ALSO">SEE ALSO</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlcn.html#AUTHORS">AUTHORS</a>
              </li>
          </ul>

      <p>如果你用一般的文字编辑器阅览这份文件, 请忽略文中奇特的注记字符. 这份文件是以 POD (简明文件格式) 写成; 这种格式是为了能让人直接阅读, 而特别设计的. 关于此格式的进一步信息, 请参考 perlpod 在线文档.</p>

<h1 id="NAME"><a class="permalink" href="perlcn.html#NAME">#</a>NAME</h1>

<p>perlcn - 简体中文 Perl 指南</p>

<h1 id="DESCRIPTION"><a class="permalink" href="perlcn.html#DESCRIPTION">#</a>DESCRIPTION</h1>

<p>欢迎来到 Perl 的天地!</p>

<p>从 5.8.0 版开始, Perl 具备了完善的 Unicode (统一码) 支持, 也连带支持了许多拉丁语系以外的编码方式; CJK (中日韩) 便是其中的一部分. Unicode 是国际性的标准, 试图涵盖世界上所有的字符: 西方世界, 东方世界, 以及两者间的一切 (希腊文, 叙利亚文, 阿拉伯文, 希伯来文, 印度文, 印地安文, 等等). 它也容纳了多种操作系统与平台 (如 PC 及麦金塔).</p>

<p>Perl 本身以 Unicode 进行操作. 这表示 Perl 内部的字符串数据可用 Unicode 表示; Perl 的函数与运算符 (例如正则表达式匹配) 也能对 Unicode 进行操作. 在输入及输出时, 为了处理以 Unicode 之前的编码方式储存的数据, Perl 提供了 Encode 这个模块, 可以让你轻易地读写使用旧有的编码格式的数据.</p>

<p>Encode 扩展模块支持下列简体中文的编码方式 (&#39;gb2312&#39; 表示 &#39;euc-cn&#39;):</p>

<pre><code class="plaintext">euc-cn	Unix 扩展字符集, 也就是俗称的国标码
gb2312-raw	未经处理的 (低比特) GB2312 字符表
gb12345	未经处理的中国用繁体中文编码
iso-ir-165	GB2312 + GB6345 + GB8565 + 新增字符
cp936	字码页 936, 也可以用 &#39;GBK&#39; (扩充国标码) 指明
hz		7 比特逸出式 GB2312 编码</code></pre>

<p>举例来说, 将 EUC-CN 编码的文件转成 Unicode, 只需输入以下命令:</p>

<pre><code class="plaintext">perl -Mencoding=euc-cn,STDOUT,utf8 -pe1 &lt; file.euc-cn &gt; file.utf8</code></pre>

<p>Perl 也内附了 &quot;piconv&quot;, 一个完全以 Perl 写成的字符转换工具程序, 用法如下:</p>

<pre><code class="plaintext">piconv -f euc-cn -t utf8 &lt; file.euc-cn &gt; file.utf8
piconv -f utf8 -t euc-cn &lt; file.utf8 &gt; file.euc-cn</code></pre>

<p>另外, 利用 encoding 模块, 你可以轻易写出以字符为单位的代码, 如下所示:</p>

<pre><code>#!/usr/bin/env perl
# 启动 euc-cn 字串解析; 标准输出入及标准错误都设为 euc-cn 编码
use encoding &#39;euc-cn&#39;, STDIN =&gt; &#39;euc-cn&#39;, STDOUT =&gt; &#39;euc-cn&#39;;
print length(&quot;骆驼&quot;);	     #  2 (双引号表示字符)
print length(&#39;骆驼&#39;);	     #  4 (单引号表示字节)
print index(&quot;谆谆教诲&quot;, &quot;蛔唤&quot;); # -1 (不包含此子字符串)
print index(&#39;谆谆教诲&#39;, &#39;蛔唤&#39;); #  1 (从第二个字节开始)</code></pre>

<p>在最后一列例子里, &quot;谆&quot; 的第二个字节与 &quot;谆&quot; 的第一个字节结合成 EUC-CN 码的 &quot;蛔&quot;; &quot;谆&quot; 的第二个字节则与 &quot;教&quot; 的第一个字节结合成 &quot;唤&quot;. 这解决了以前 EUC-CN 码匹配处理上常见的问题.</p>

<h2 id="额外的中文编码"><a class="permalink" href="perlcn.html#%E9%A2%9D%E5%A4%96%E7%9A%84%E4%B8%AD%E6%96%87%E7%BC%96%E7%A0%81">#</a><a id=""></a>额外的中文编码</h2>

<p>如果需要更多的中文编码, 可以从 CPAN (<a href="https://www.cpan.org/">https://www.cpan.org/</a>) 下载 Encode::HanExtra 模块. 它目前提供下列编码方式:</p>

<pre><code class="plaintext">gb18030	扩充过的国标码, 包含繁体中文</code></pre>

<p>另外, Encode::HanConvert 模块则提供了简繁转换用的两种编码:</p>

<pre><code class="plaintext">big5-simp	Big5 繁体中文与 Unicode 简体中文互转
gbk-trad	GBK 简体中文与 Unicode 繁体中文互转</code></pre>

<p>若想在 GBK 与 Big5 之间互转, 请参考该模块内附的 b2g.pl 与 g2b.pl 两个程序, 或在程序内使用下列写法:</p>

<pre><code>use Encode::HanConvert;
$euc_cn = big5_to_gb($big5); # 从 Big5 转为 GBK
$big5 = gb_to_big5($euc_cn); # 从 GBK 转为 Big5</code></pre>

<h2 id="进一步的信息"><a class="permalink" href="perlcn.html#%E8%BF%9B%E4%B8%80%E6%AD%A5%E7%9A%84%E4%BF%A1%E6%81%AF">#</a><a id="1"></a>进一步的信息</h2>

<p>请参考 Perl 内附的大量说明文件 (不幸全是用英文写的), 来学习更多关于 Perl 的知识, 以及 Unicode 的使用方式. 不过, 外部的资源相当丰富:</p>

<h2 id="提供-Perl-资源的网址"><a class="permalink" href="perlcn.html#%E6%8F%90%E4%BE%9B-Perl-%E8%B5%84%E6%BA%90%E7%9A%84%E7%BD%91%E5%9D%80">#</a><a id="提供"></a><a id="Perl"></a>提供 Perl 资源的网址</h2>

<dl>

<dt id="https://www.perl.org/"><a class="permalink" href="perlcn.html#https://www.perl.org/">#</a><a id="https"></a><a id="https:-www.perl.org"></a><a href="https://www.perl.org/">https://www.perl.org/</a></dt>
<dd>

</dd>
</dl>

<p>Perl 的首页</p>

<dl>

<dt id="https://www.perl.com/"><a class="permalink" href="perlcn.html#https://www.perl.com/">#</a><a id="https1"></a><a id="https:-www.perl.com"></a><a href="https://www.perl.com/">https://www.perl.com/</a></dt>
<dd>

<p>由 Perl 基金会运营的文章辑录</p>

</dd>
<dt id="https://www.cpan.org/"><a class="permalink" href="perlcn.html#https://www.cpan.org/">#</a><a id="https2"></a><a id="https:-www.cpan.org"></a><a href="https://www.cpan.org/">https://www.cpan.org/</a></dt>
<dd>

<p>Perl 综合典藏网 (Comprehensive Perl Archive Network)</p>

</dd>
<dt id="https://lists.perl.org/"><a class="permalink" href="perlcn.html#https://lists.perl.org/">#</a><a id="https3"></a><a id="https:-lists.perl.org"></a><a href="https://lists.perl.org/">https://lists.perl.org/</a></dt>
<dd>

<p>Perl 邮递论坛一览</p>

</dd>
</dl>

<h2 id="学习-Perl-的网址"><a class="permalink" href="perlcn.html#%E5%AD%A6%E4%B9%A0-Perl-%E7%9A%84%E7%BD%91%E5%9D%80">#</a><a id="学习"></a><a id="Perl1"></a>学习 Perl 的网址</h2>

<dl>

<dt id="http://www.oreilly.com.cn/index.php?func=booklist&amp;cat=68"><a class="permalink" href="perlcn.html#http://www.oreilly.com.cn/index.php?func=booklist&amp;cat=68">#</a><a id="http"></a><a id="http:-www.oreilly.com.cn-index.php-func-booklistcat-68"></a><a href="http://www.oreilly.com.cn/index.php?func=booklist&amp;cat=68">http://www.oreilly.com.cn/index.php?func=booklist&amp;cat=68</a></dt>
<dd>

<p>简体中文版的欧莱礼 Perl 书藉</p>

</dd>
</dl>

<h2 id="Perl-使用者集会"><a class="permalink" href="perlcn.html#Perl-%E4%BD%BF%E7%94%A8%E8%80%85%E9%9B%86%E4%BC%9A">#</a><a id="Perl2"></a>Perl 使用者集会</h2>

<dl>

<dt id="https://www.pm.org/groups/asia.html"><a class="permalink" href="perlcn.html#https://www.pm.org/groups/asia.html">#</a><a id="https4"></a><a id="https:-www.pm.org-groups-asia.html"></a><a href="https://www.pm.org/groups/asia.html">https://www.pm.org/groups/asia.html</a></dt>
<dd>

<p>中国 Perl 推广组一览</p>

</dd>
</dl>

<h2 id="Unicode-相关网址"><a class="permalink" href="perlcn.html#Unicode-%E7%9B%B8%E5%85%B3%E7%BD%91%E5%9D%80">#</a><a id="Unicode"></a>Unicode 相关网址</h2>

<dl>

<dt id="https://www.unicode.org/"><a class="permalink" href="perlcn.html#https://www.unicode.org/">#</a><a id="https5"></a><a id="https:-www.unicode.org"></a><a href="https://www.unicode.org/">https://www.unicode.org/</a></dt>
<dd>

<p>Unicode 学术学会 (Unicode 标准的制定者)</p>

</dd>
<dt id="https://www.cl.cam.ac.uk/%7Emgk25/unicode.html"><a class="permalink" href="perlcn.html#https://www.cl.cam.ac.uk/%257Emgk25/unicode.html">#</a><a id="https6"></a><a id="https:-www.cl.cam.ac.uk-7Emgk25-unicode.html"></a><a href="https://www.cl.cam.ac.uk/%7Emgk25/unicode.html">https://www.cl.cam.ac.uk/%7Emgk25/unicode.html</a></dt>
<dd>

<p>Unix/Linux 上的 UTF-8 及 Unicode 常见问题解答</p>

</dd>
</dl>

<h1 id="SEE-ALSO"><a class="permalink" href="perlcn.html#SEE-ALSO">#</a><a id="SEE"></a>SEE ALSO</h1>

<p><a href="Encode.html">Encode</a>, <a href="./Encode::CN.html">Encode::CN</a>, <a href="encoding.html">encoding</a>, <a href="perluniintro.html">perluniintro</a>, <a href="perlunicode.html">perlunicode</a></p>

<h1 id="AUTHORS"><a class="permalink" href="perlcn.html#AUTHORS">#</a>AUTHORS</h1>

<p>Jarkko Hietaniemi &lt;jhi@iki.fi&gt;</p>

<p>Audrey Tang (唐凤) &lt;audreyt@audreyt.org&gt;</p>

<p>Sizhe Zhao &lt;prc.zhao@outlook.com&gt;</p>


      </div>
      <div id="footer">
        <p>Perldoc Browser is maintained by Dan Book (<a href="https://metacpan.org/author/DBOOK">DBOOK</a>). Please contact him via the <a href="https://github.com/Grinnz/perldoc-browser/issues">GitHub issue tracker</a> or <a href="mailto:dbook@cpan.org">email</a> regarding any issues with the site itself, search, or rendering of documentation.</p>

<p>The Perl documentation is maintained by the Perl 5 Porters in the development of Perl. Please contact them via the <a href="https://github.com/Perl/perl5/issues">Perl issue tracker</a>, the <a href="https://lists.perl.org/list/perl5-porters.html">mailing list</a>, or <a href="https://kiwiirc.com/client/irc.perl.org/p5p">IRC</a> to report any issues with the contents or format of the documentation.</p>


      </div>
    </div>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.slim.min.js" integrity="sha512-/DXTXr6nQodMUiq+IUJYCt2PPOUjrHJ9wFrqpJ3XkgPNOZVfMok7cRw6CSxyCQxXn6ozlESsSh1/sMCTF1rL/g==" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.1/umd/popper.min.js" integrity="sha512-ubuT8Z88WxezgSqf3RLuNi5lmjstiJcyezx34yIU2gAHonIi27Na7atqzUZCOoY4CExaoFumzOsFQ2Ch+I/HCw==" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV" crossorigin="anonymous"></script>
    <script src="../highlight.pack.js"></script>
    <script>hljs.highlightAll();</script>
  </body>
</html>
